
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/preferred_size.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'package:pocketfile/common/base/base_controller.dart';
import 'package:pocketfile/common/base/base_view.dart';
import 'package:pocketfile/module/home/page/home_page.dart';
import 'package:pocketfile/module/mine/page/mine_page.dart';
import 'package:pocketfile/module/root/controller/root_controller.dart';
import 'package:pocketfile/module/root/model/menu_code.dart';
import 'package:pocketfile/module/root/widget/bottom_nav_bar.dart';

class RootPage extends BaseView<RootController> {
  @override
  PreferredSizeWidget? appBar(BuildContext context) {
    // TODO: implement appBar
    return null;
  }

  @override
  Widget body(BuildContext context) {
    // TODO: implement body
    return  Obx(() => getPageOnSelectedMenu(controller.selectedMenuCode));
  }

  @override
  Widget? bottomNavigationBar() {
    return BottomNavBar(onNewMenuSelected: controller.onMenuSelected);
  }

  final HomePage homePage = HomePage();
  MinePage? minePage;

  Widget getPageOnSelectedMenu(MenuCode menuCode) {
    switch (menuCode) {
      case MenuCode.HOME:
        return homePage;
      case MenuCode.MINE:
        minePage ??= MinePage();
        return minePage!;
    }
  }

}